﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace NamingOnLessonUtility
{
    public class ConfigHelper
    {
        /// <summary>
        /// 根据Key取Value值
        /// </summary>
        /// <param name="key"></param>
        public static string AppSettings(string key)
        {
            try
            {
                return ConfigurationManager.AppSettings[key].ToString().Trim();
            }
            catch (Exception ex)
            {
                return "";
            }
        }
        /// <summary>
        /// 根据连接名获取连接字符串
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string GetConnSettingsValue(string key)
        {
            ConfigurationManager.RefreshSection("connectionStrings");
            ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[key];
            return settings.ConnectionString;
        }
    }
}
